<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<atleap:javascript formName="testimonialForm" staticJavascript="false" dynamicJavascript="true" method="validateForm" cdata="false" />
<atleap:content identifier="information" ignore="true" />
<atleap:message key="testimonials.errors.body.nothingChecked" var="errorMessage" />
<c:set var="dontNeedCheckBoxes" value="${testimonialForm.localesMode != 'selected'}" />
<c:set var="hasCheckBoxValidation" value="hasCheckedBox(this, 'toggleAll', &#039;${errorMessage}&#039;)" />
<atleap:form action="testimonials/callCreateTestimonialBody" method="POST" onsubmit="var isValidForm = bCancel ? true : (validateForm(this) && ${dontNeedCheckBoxes ? 'true' : hasCheckBoxValidation}); disableButtons(this, isValidForm); return isValidForm;">
	<table cellpadding="0"  cellspacing="0" border="0" class="modificationTable">
		<tr>
			<td colspan="2" align="center">
				<atleap:label property="title" key="testimonials.form.title" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						*&nbsp;<atleap:message key="testimonials.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
					<html:text maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}"  property="title(${contentLocale.identifier})" styleClass="text" />
				</td>
			</tr>
		</atleap:iterator>
	</table>

    <c:if test="${!dontNeedCheckBoxes}">
        <%-- List of body values for this testimonial --%>
        <tiles:insert definition=".core.contentLocale.selectLocales" flush="false">
            <tiles:put name="listTitleKey" value="testimonials.item.body.list" direct="true" />
            <tiles:put name="nothingCheckedErrorKey" value="testimonials.errors.body.nothingChecked" direct="true" />
            <tiles:put name="languageKey" value="testimonials.form.language" direct="true" />
            <tiles:put name="checkedBoxProperty" value="bodyCheckedBox" direct="true" />
        </tiles:insert>
    </c:if>

    <atleap:iterator items="${testimonialForm.bodyMap}" var="entry">
        <html:hidden property="body(${entry.key})" />
    </atleap:iterator>

	<html:hidden property="uri" value="/testimonials" />
    <html:hidden property="localesMode" />
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.next" /></atleap:submit>
</atleap:form>
